<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>
    $(document).ready(function(){
        $("#contentTable").treeTable();
        //读卡查询
        $("#cardQuery").on('click',function(){
            var cardNo = readOneCard();
            if (!cardNo) {
                toastr.error("读卡失败");
                return false;
            }else{
                $("#cardFlag").val("1");
                $("#cardNo").val(cardNo);
                $("#searchFormService").submit();
            }
        })

        $("#btnSubmit").on('click',function(){
            $("#cardFlag").val("0");
            $("#cardNo").val("");
            $("#searchFormService").submit();
        })
    });
    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchFormService").submit();
        return false;
    }
    function print(serialNo){
        printPdf('${ctx}/finance/outpRcptMaster/printCharge','serialNo='+serialNo);
    }
</script>
<div class="app">
        <div class="content-wrap">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#">收费查询</a>
                </li>
            </ul>
            <div class="row" id="topDivId">
                    <section class="panel">
                        <div class="panel-body">
                            <div class="table-responsive no-border">
                                <div class="datatable-top">
                                    <div class="pull-left">
                                        <form id="searchFormService"  onsubmit="return loadDivForm('mainCenterDiv','searchFormService','${ctx}/finance/outpRcptMaster/searchRcptMaster');" method="post" class="form-inline">
                                            <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                            <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                                            <input type="hidden"id="cardFlag" value="${outpRcptMaster.cardFlag}" name="cardFlag"/>
                                            <input type="hidden"id="cardNo" value="${outpRcptMaster.cardNo}" name="cardNo"/>
                                            <label>计费日期：</label><input name="tollStartTime" value="${outpRcptMaster.tollStartTime}"  id="startTime"  class="form-control Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>&nbsp;
                                            至<input name="tollEndTime" value="${outpRcptMaster.tollEndTime}" id="endTime"  class="form-control Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
                                            <label>病人姓名:</label><input name="patMasterIndex.name" value="${outpRcptMaster.patMasterIndex.name}" class="form-control">
                                            <label>合计费用:</label><input name="totalCosts" class="form-control">
                                            &nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" value="查询"/>
                                            &nbsp;<input id="cardQuery" class="btn btn-primary" type="button" value="读卡查询"/>
                                        </form>
                                    </div>
                                </div>
                            <table id="contentTable" class="table table-bordered mg-t datatable">
                                <thead>
                                  <tr>
                                      <th>收费日期</th>
                                      <th>收费单号</th>
                                      <th>结账号</th>
                                      <th>病人姓名</th>
                                      <th>应收</th>
                                      <th>实收</th>
                                      <th>操作</th>
                                  </tr>
                                </thead>
                                <tbody>
                                 <c:forEach items="${page.list}" var="rcptMaster" varStatus="ma">
                                   <tr id="${rcptMaster.id}">
                                       <td><fmt:formatDate value="${rcptMaster.createDate}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                                       <td>${rcptMaster.rcptNo}</td>
                                       <td>${rcptMaster.acctNo}</td>
                                       <td>${rcptMaster.patientId}</td>
                                       <td>${rcptMaster.totalCosts}</td>
                                       <td>${rcptMaster.totalCharges}</td>
                                       <td><a href="#"  class="btn btn-success btn-xs" onclick=print('${rcptMaster.serialNo}')>打印</a></td>
                                   </tr>
                                     <c:if test="${rcptMaster.outpBillItemsList.size()>0}">
                                         <tr id="${ma.count}" pid="${rcptMaster.id}">
                                             <td colspan="6">
                                                 <table class="table table-bordered mg-t">
                                                     <tr>
                                                         <th>序号</th>
                                                         <th>项目代码</th>
                                                         <th>项目名称</th>
                                                         <th>数量</th>
                                                         <th>应收</th>
                                                         <th>实收</th>
                                                     </tr>
                                                     <c:forEach items="${rcptMaster.outpBillItemsList}" var="item" varStatus="ss">
                                                         <tr>
                                                             <td> ${ss.count}</td>
                                                             <td> ${item.itemCode}</td>
                                                             <td> ${item.itemName}</td>
                                                             <td> ${item.num}</td>
                                                             <td> ${item.costs}</td>
                                                             <td> ${item.charges}</td>
                                                         </tr>
                                                     </c:forEach>
                                                 </table>
                                             </td>
                                         </tr>
                                     </c:if>
                                 </c:forEach>
                                </tbody>
                            </table>
                            <div class="pagination">${page}</div>
                         </div>
                        </div>
                    </section>
            </div>
        </div>
</div>
</div>
</div>